<?php

/**
 * services actions.
 *
 * @package    jobeet
 * @subpackage services
 * @author     Your name here
 */
class servicesActions extends sfActions
{
  public function executeIndex(sfWebRequest $request)
  {
    $this->Servicess = ServicesQuery::create()->find();
    $this->sTitle = "Фотограф на свадьбу. Светлогорск, Беларусь";
  }

  public function executeShow(sfWebRequest $request)
  {
    $this->Services = ServicesPeer::retrieveByPk($request->getParameter('id'));
    $this->forward404Unless($this->Services);
  }

  public function executeNew(sfWebRequest $request)
  {
    $this->form = new ServicesForm();
  }

  public function executeCreate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new ServicesForm();

    $this->processForm($request, $this->form);

    $this->setTemplate('new');
  }

  public function executeEdit(sfWebRequest $request)
  {
    $Services = ServicesQuery::create()->findPk($request->getParameter('id'));
    $this->forward404Unless($Services, sprintf('Object Services does not exist (%s).', $request->getParameter('id')));
    $this->form = new ServicesForm($Services);
  }

  public function executeUpdate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $Services = ServicesQuery::create()->findPk($request->getParameter('id'));
    $this->forward404Unless($Services, sprintf('Object Services does not exist (%s).', $request->getParameter('id')));
    $this->form = new ServicesForm($Services);

    $this->processForm($request, $this->form);

    $this->setTemplate('edit');
  }

  public function executeDelete(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $Services = ServicesQuery::create()->findPk($request->getParameter('id'));
    $this->forward404Unless($Services, sprintf('Object Services does not exist (%s).', $request->getParameter('id')));
    $Services->delete();

    $this->redirect('services/index');
  }

  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $Services = $form->save();

      $this->redirect('services/edit?id='.$Services->getId());
    }
  }
}
